home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games 1996 December / Amiga Games 1996 #12.iso / rexx / checkarc.vzrx < prev    next >
Text File  |  1996-09-10  |  3KB  |  109 lines

  1. /*
  2.    $VER: CheckArc.vzrx 1.01 (1.10.95)
  3.          © 1995 by Georg Hörmann
  4.  
  5.    Template: CheckArc.vzrx ARC/A,QUIT/S
  6.  
  7.       ARC:  The filename (with path) of the archive.
  8.       QUIT: If VirusZ has been started from the script, you can
  9.             quit after checking by specifying this option.
  10.  
  11.    If VirusZ is not running, it will be started from the
  12.    script (and quitted afterwards if requested).
  13.  
  14.    Currently the type of archive is determined by the filename
  15.    suffixes ".lha", ".lzh" and ".lzx". This should usually work
  16.    properly as nobody ever removes the suffixes of archive names.
  17. */
  18.  
  19. /* Filenames of external programs */
  20. Prog_VirusZ = "dh0:VZ"
  21. Prog_LHA = "Boot:Tools/LHA"
  22. Prog_LZX = "Boot:Tools/LZX"
  23. Prog_Delete = "C:Delete"
  24.  
  25. TempPath = "RAM:TempArcDir"
  26.  
  27. options results
  28. options failat 99
  29.  
  30. UseQuitFlag = "no"
  31.  
  32. parse upper arg ArcToCheck QuitFlag
  33. if ArcToCheck = "" then do
  34.     say "No archive specified."
  35.     exit
  36.     end
  37.  
  38. TypeFlag = index(ArcToCheck,.LHA) + index(ArcToCheck,.LZH) + index(ArcToCheck,.LZX)
  39. if TypeFlag = 0 then do
  40.     say "Archive not of required type."
  41.     exit
  42.     end
  43.  
  44. if ~show(ports,VIRUSZ_II.REXX) then do
  45.     say "Starting VirusZ..."
  46.     address command Prog_VirusZ
  47.     UseQuitFlag = "yes"
  48.     StartTime = time(seconds)
  49.     do while ~show(ports,VIRUSZ_II.REXX)
  50.         if time(seconds) - StartTime > 20 then do
  51.             say "Error loading VirusZ!"
  52.             exit
  53.             end
  54.         end
  55.     end
  56.  
  57. if exists(TempPath) then do
  58.     say "Deleting temporary directory..."
  59.     address command Prog_Delete ">NIL: <NIL:" TempPath ALL
  60.     if rc~=0 then do
  61.         say "Error deleting temporary directory!"
  62.         signal QuitVirusZ
  63.         end
  64.     end
  65.  
  66. TypeFlag = index(ArcToCheck,.LHA) + index(ArcToCheck,.LZH)
  67. if TypeFlag ~= 0 then do
  68.     say "Extracting .LHA/.LZH archive..."
  69.     address command Prog_LHA ">NIL: <NIL: x "ArcToCheck TempPath"/"
  70.     if rc~=0 then do
  71.         say "Error extracting archive!"
  72.         signal DeleteTemp
  73.         end
  74.     end
  75. else do
  76.     say "Extracting .LZX archive..."
  77.     address command Prog_LZX ">NIL: <NIL: x "ArcToCheck TempPath"/"
  78.     if rc~=0 then do
  79.         say "Error extracting archive!"
  80.         signal DeleteTemp
  81.         end
  82.     end
  83.  
  84. if exists(TempPath) then do
  85.     say "Checking archive contents..."
  86.     address VIRUSZ_II.REXX CHECKDIR TempPath DECREXEC DECRDATA
  87.     if rc=0 then say "Archive is clean."
  88.     if rc=5 then say "Archive contains virus(es)!"
  89.     if rc=10 then say "Error checking archive!"
  90.     end
  91.  
  92. DeleteTemp:
  93. if exists(TempPath) then do
  94.     say "Deleting temporary directory..."
  95.     address command Prog_Delete ">NIL: <NIL:" TempPath ALL
  96.     if rc~=0 then do
  97.         say "Error deleting temporary directory!"
  98.         signal QuitVirusZ
  99.         end
  100.     end
  101.  
  102. QuitVirusZ:
  103. if UseQuitFlag = "yes" then do
  104.     if QuitFlag = "QUIT" then do
  105.         say "Quitting VirusZ..."
  106.         address VIRUSZ_II.REXX QUIT
  107.         end
  108.     end
  109.